]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
inputMethod: Protect for running with older mutter versions
authorCarlos Garnacho <carlosg@gnome.org>
Sat, 28 Mar 2020 16:26:39 +0000 (17:26 +0100)
committerFlorian Müllner <florian.muellner@gmail.com>
Sat, 28 Mar 2020 16:38:10 +0000 (16:38 +0000)
The offset argument is changing from uint to int. Which means we
might would pass a negative offset and trigger an "out of bounds"
error. Make it work more or less alright with older mutters, by
clamping the offset to 0.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1146

js/misc/inputMethod.js

index 386c07a75ae47f06847e3fcd020fb6a65f37c84d..a3c6bb084e6194cee98b6a0d7472b9bdeb15bd0d 100644 (file)
@@ -98,7 +98,12 @@ class InputMethod extends Clutter.InputMethod {
     }
 
     _onDeleteSurroundingText(_context, offset, nchars) {
-        this.delete_surrounding(offset, nchars);
+        try {
+            this.delete_surrounding(offset, nchars);
+        } catch (e) {
+            // We may get out of bounds for negative offset on older mutter
+            this.delete_surrounding(0, nchars + offset);
+        }
     }
 
     _onUpdatePreeditText(_context, text, pos, visible) {